package com.qf.controller.medicineAudit;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.DrugTypes;
import com.qf.entity.MedicineAudit;
import com.qf.entity.Product;
import com.qf.service.medicineAudit.MedicineAuditService;
import com.qf.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- 永无霸哥 ---
 *
 * @author M.rk
 * @date 2024/12/7 20:35
 * @desc
 */
@RestController
@RequestMapping("/MedicineAudit")
@Slf4j
public class MedicineAuditController {
    @Autowired
    MedicineAuditService medicineAuditService;

    //新增
    @PostMapping("/newAudit")
    public R newAudit(@RequestBody MedicineAudit medicineAudit) {
        int i = medicineAuditService.newAudit(medicineAudit);

        if(i > 0){
            return R.ok();
        }

        return  R.fail();
    }




    //查询
    @GetMapping("/examineList")
    public R examineList(MedicineAudit medicineAudit) {
        PageHelper.startPage(medicineAudit.getPageNum(), medicineAudit.getPageSize());

        List<MedicineAudit> list = medicineAuditService.examineList(medicineAudit);

        PageInfo<MedicineAudit> PageInfo = new PageInfo(list);

        if(PageInfo != null){
            return R.ok(PageInfo);
        }


        return  R.fail();

    }

}
